package system_storage_service

import (
	"gitee.com/Luna-CY/Golang-Project-Template/internal/context"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/interface/dao"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/logger"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

func (cls *Storage) GetObjectByCondition(ctx context.Context, options ...dao.SystemObjectOption) (*model.SystemObject, errors.Error) {
	if 0 == len(options) {
		logger.SugarLogger(logger.WithRequestId(ctx), logger.WithStack()).Errorf("ISS_GE.S_GE.GOBC_ON.133020 options is empty")

		return nil, errors.ErrorServerInternalError("ISS_GE.S_GE.GOBC_ON.150919", "异常的传入参数")
	}

	object, err := cls.object.TakeSystemObjectByCondition(ctx, options...)
	if err != nil {
		return nil, err.Relation(errors.ErrorServerInternalError("ISS_GE.S_GE.GOBC_ON.200922", "查询对象失败"))
	}

	return object, nil
}
